package generic;

import org.junit.Test;

public class NumberTest {

    @Test
    public void shortToHex() {
        short shortN = (short)0x9301;
        int intN = 0x9301;
        int intN2 = shortN;
        
        log("shortN = " + shortN + " " + Integer.toBinaryString(shortN));
        log("intN = " + intN + " " + Integer.toBinaryString(intN));
        log("intN2 = " + intN2);
        
        // 打印字节流
        byte a1 = (byte)(shortN & 0xFF);
        byte a2 = (byte)(shortN>>8 & 0xFF);
        log("a1=" + a1);
        log("a2=" + a2);
    }
    
    private void log(String msg) {
        System.out.println(msg);
    }
}
